

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;

namespace DataLayer
{
	public class datPages
	{
		public datPages()
		{
		}

        #region  Code Factory Generated Methods
        public void DeletePagesByPageId(entPages parEntPages, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPageId", parEntPages.PageId);
            parDbConnector.ExecuteNonQuery("DeletePagesByPageId", insDbParamCollection);
        }
        public void InsertPages(entPages parEntPages, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPageId", parEntPages.PageId);
            insDbParamCollection.Add("@pPageClassName", parEntPages.PageClassName);
            insDbParamCollection.Add("@pPageDescription", parEntPages.PageDescription);
            insDbParamCollection.Add("@pIsAdminPage", parEntPages.IsAdminPage);
            parDbConnector.ExecuteNonQuery("InsertPages", insDbParamCollection);
            parEntPages.PageId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
        }
        public void UpdatePagesByPageId(entPages parEntPages, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();

            insDbParamCollection.Add("@pPageId", parEntPages.PageId);
            insDbParamCollection.Add("@pPageClassName", parEntPages.PageClassName);
            insDbParamCollection.Add("@pPageDescription", parEntPages.PageDescription);
            insDbParamCollection.Add("@pIsAdminPage", parEntPages.IsAdminPage);
            parDbConnector.ExecuteNonQuery("UpdatePagesByPageId", insDbParamCollection);
        }
        public DataTable SelectPages(DbConnector parDbConnector)
        {

            return parDbConnector.ExecuteDataTable("SelectPages", null);
        }
        public void SelectPagesByPageId(entPages parEntPages, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pPageId", parEntPages.PageId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectPagesByPageId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["PageId"] != DBNull.Value)
                {
                    parEntPages.PageId = Convert.ToInt32(insDataTable.Rows[0]["PageId"]);
                }
                if (insDataTable.Rows[0]["PageClassName"] != DBNull.Value)
                {
                    parEntPages.PageClassName = insDataTable.Rows[0]["PageClassName"].ToString();
                }
                if (insDataTable.Rows[0]["PageDescription"] != DBNull.Value)
                {
                    parEntPages.PageDescription = insDataTable.Rows[0]["PageDescription"].ToString();
                }
                if (insDataTable.Rows[0]["IsAdminPage"] != DBNull.Value)
                {
                    parEntPages.IsAdminPage = Convert.ToBoolean(insDataTable.Rows[0]["IsAdminPage"]);
                }
            }
        }
       
        #endregion
	}
}